class GameSceneManager extends egret.Sprite{
    
    public static instance:GameSceneManager = null;
    private gameLayer:Main = null;
    private runninglayer: egret.DisplayObject = null;
    private stackLayer = [];

    public static getInstance() {
        if (GameSceneManager.instance == null) {
            GameSceneManager.instance = new GameSceneManager();
        }
        return GameSceneManager.instance;
    }    
    
    public initWithMain(m:Main) {
        if (this.gameLayer == null) {
            this.gameLayer = m;
        }

    }

    public constructor() {
        super();        
    }  
    
    //替换场景
    public repleaceScene(layer:egret.DisplayObject) {
        if (this.gameLayer != null && layer != null) {
            this.gameLayer.removeChildren();
            this.gameLayer.addChild(layer);
            this.runninglayer = layer;
        }
    }
    //添加场景
    public pushScene(layer:egret.DisplayObject) {
        if (this.gameLayer != null && layer != null) {
            this.gameLayer.addChild(layer);
            this.stackLayer.push(layer);
            this.runninglayer = layer;
        }
    }

    public getRunningScene() : egret.DisplayObject {
        return this.runninglayer;
    }

}
